package annotation;

import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

/**
 * Created by Administrator on 2017/6/13.
 */
public class Main {
    public static void main(String[] args) {
    //    获取注解class实例
        Class<Test> annotation = Test.class;
        Field[] fields =  annotation.getDeclaredFields();
        for (int i=0;i<fields.length;i++)
                if(fields[i].isAnnotationPresent(Hello.class)){
                    System.out.println(fields[i].getName()+"域名包含Hello注解");
                    //                    得到该注解上的值
               Hello annotation1 = fields[i].getAnnotation(Hello.class);
               System.out.println("注解上的值是："+annotation1.str());
        }


    }
}
